# @shuaige : 陈世玉
# @name :ScoreData.py
# @time :2024/12/10 11:07
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.render import make_snapshot
from snapshot_selenium import snapshot
from pyecharts.globals import ThemeType
with open('data.csv','r',encoding='utf-8') as f:
    lines=f.readlines()
    lines=lines[1:21]
    name=[]
    rank=[]
    score=[]
    for i in range(len(lines)):
        name.append(lines[i].split(',')[2].strip())
        rank.append(lines[i].split(',')[1].strip())
        score.append(lines[i].split(',')[6].strip())
    bar = Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))
    bar.add_xaxis(name)
    bar.add_yaxis('排名',rank)
    bar.add_yaxis('评分',score)
    # 全局配置
    # bar.set_global_opts(title_opts=opts.TitleOpts(title='主标题',subtitle='副标题'))
    bar.set_global_opts(title_opts={'text':'十月份前二十车型','subtext':'排行评分对比'})
    # make_snapshot(snapshot,bar.render(),'bar.png')
    bar.render('Score.html')
